﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.AnalysisServices;

namespace SsasAutomation
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Server server = new Server();
            server.Connect("Provider=MSOLAP.4;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=TPA_SSASP;Data Source=.");
            //server.Databases["TPA_SSASP"].Process(ProcessType.ProcessFull);
            foreach (Dimension d in server.Databases["TPA_SSASP"].Dimensions)
            {
                d.Process(ProcessType.ProcessFull);
                label1.Text += d.Name + " processed successfully.\r\n";
            }
            foreach (Cube c in server.Databases["TPA_SSASP"].Cubes)
            {
                c.Process(ProcessType.ProcessFull);
                label1.Text += "Cube "+c.Name + " processed successfully. \r\n";
            }
            server.Disconnect();
        }
    }
}
